public class Modifier 
{
	final int constantModifier;
	final double sourceAttributeMultipilier;
	final double targetAttributeMultipilier;
	final Attribute sourceAttribute;
	final Attribute targetAttribute;
	final Attribute modyfiingAttribute;
	
	/*
	 * modyfiingAttribute += 	constantModifier + 
	 * 							sourceAttributeMultipilier * sourceAttribute + 
	 * 							targetAttributeMultipilier * targetAttribute
	 * 
	 * */
	
	public  Modifier(int constant, double sAM, double tAM, Attribute source, Attribute target, Attribute modyfing) 
	{
		sourceAttributeMultipilier = sAM;
		targetAttributeMultipilier = tAM;
		targetAttribute = target;
		sourceAttribute = source;
		modyfiingAttribute = modyfing;
		constantModifier = constant;
	}
	
	public void action(Client source, Client target)
	{
		Attribute aFromSource = source.connectedPlayer.getAttribute(sourceAttribute);
		Attribute aFromTarget = target.connectedPlayer.getAttribute(targetAttribute);
		Attribute aModyfing = target.connectedPlayer.getAttribute(modyfiingAttribute);
		/*System.err.println("source =" + aFromSource.value);
		System.err.println("target =" + aFromTarget.value);
		System.err.println("mod =" + aModyfing.value);*/
		int effect =(int)(constantModifier + aFromSource.getValue() * sourceAttributeMultipilier + aFromTarget.getValue() * targetAttributeMultipilier);
		/*System.err.println("e=" + effect);
		System.err.println(constantModifier);
		System.err.println(aFromSource.getValue() * sourceAttributeMultipilier);
		System.err.println(aFromTarget.getValue() * targetAttributeMultipilier);*/
		aModyfing.setEffect(effect);
		//System.err.println("value=" + aModyfing.value);
	}
	
	public boolean equals(Object object)
	{
		Modifier rv = (Modifier)object;
		if(rv == null)
		{
			return false;
		}
		if(	constantModifier 			==  rv.constantModifier &&
			sourceAttributeMultipilier 	== 	rv.sourceAttributeMultipilier &&
			targetAttributeMultipilier 	== 	rv.targetAttributeMultipilier &&
			sourceAttribute.			equals(rv.sourceAttribute)  &&
			targetAttribute.			equals(rv.targetAttribute) &&
			modyfiingAttribute.			equals(rv.modyfiingAttribute))
		{
			return true;
		}
		return false;
	}
	
	public String toString()
	{
		return new String(	constantModifier + ";" +
							sourceAttributeMultipilier + ";" +
							targetAttributeMultipilier + ";" +
							sourceAttribute + ";" +
							targetAttribute + ";" +
							modyfiingAttribute + ";");
	}
}
